Skip to main content

All Questions

2votes
2answers
2kviews

sed with external script file - How to apply shell variables?

Directly on the command line, this works: $sed "s/a/X/;s/X/&a&/" file and so does using shell variables: $varin=a ; varout=X ; sed "s/$varin/$varout/;s/$varout/&$varin&/...
FelixJN's user avatar
  • 13.9k
0votes
1answer
411views

When using variable in sed it replaces entire line, instead of just the matching string

I'm new to bash and I've been trying to understand other posts that's similar, but I'm just not sure if they do the thing I need. When I don't use variables and just put in what I want to search for ...
brauown's user avatar
1vote
2answers
2kviews

elif condition in an if statement

I have this variables start=$1; end=$2; sn=${#start} en=${#end} and this if : if ( [ $# -eq 2 ] ) then elif ( [ $sn -ne 3 ] && [ -n "$(printf '%s\n' "$start" | sed 's/[0-9]//g') " ] ); then ...
bboy's user avatar
0votes
1answer
7kviews

Replace values in a variable and retain new lines in BASH

This BASH script works as expected. I have a variable ($foo) that contains lines of data, I tell bash to separate at new lines, and I loop through the variable. #!/bin/bash foo=" Original Line1 ...
JeremyCanfield's user avatar
3votes
2answers
743views

Update or append JAVA_HOME with sed

I am scripting my new VM stack and I am trying to update or append JAVA_HOME in the ~/.bashrc file I've managed to do that by running the following sed command from the command line. sed '/export[ ]...
Dawid Adach's user avatar
1vote
1answer
187views

sed in bash scripting troubleshooting

I've got the following problem regarding to sed command. What I wish to do is: sed '1 d' filename.fa | sed "1i\>filename\n" > filename_Edited.fa where the file frist line is replaced by ">...
Neuls's user avatar
2votes
1answer
66views

Trim a text without loop

input (in variable as $VAR) : 'yoo' : x'yoo' 'welcome' : x'welcome' 'we' : x'we' 'dum' : x'dum' 'test' : x'test' 'poo' : x'poo' 'D2-dog' : x'D2-dog' 'ant' : x'ant' 'rat' : x'rat' 'xmass' : x'xmass' I ...
Kasino's user avatar

close